<?php

/**
 * This is the model class for table "exit_detail".
 *
 * The followings are the available columns in table 'exit_detail':
 * @property integer $id
 * @property integer $occupant_load
 * @property integer $egress_capacity
 * @property integer $capacity_of_horizontal_exit
 * @property integer $capacity_of_exit_stair
 * @property integer $no_of_exit
 * @property integer $remote
 * @property string $location_of_exit
 * @property integer $enclosure_provided
 * @property integer $exit_accesible
 * @property string $discharge_of_exit
 * @property integer $fire_door_provided
 * @property integer $self_closing_mechanism
 * @property integer $panic_hardware
 * @property integer $inspection_id
 *
 * The followings are the available model relations:
 * @property AreaOfSafeRefuge[] $areaOfSafeRefuges
 * @property Inspection $inspection
 * @property HorizontalExit[] $horizontalExits
 * @property MainStairway[] $mainStairways
 * @property MeanOfEgress[] $meanOfEgresses
 * @property Ramp[] $ramps
 * @property SecondaryStairOrFireEscape[] $secondaryStairOrFireEscapes
 */
class ExitDetail extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return ExitDetail the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'exit_detail';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('inspection_id', 'required'),
			array('occupant_load, egress_capacity, capacity_of_horizontal_exit, capacity_of_exit_stair, no_of_exit, remote, enclosure_provided, exit_accesible, fire_door_provided, self_closing_mechanism, panic_hardware, inspection_id', 'numerical', 'integerOnly'=>true),
			array('location_of_exit, discharge_of_exit', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, occupant_load, egress_capacity, capacity_of_horizontal_exit, capacity_of_exit_stair, no_of_exit, remote, location_of_exit, enclosure_provided, exit_accesible, discharge_of_exit, fire_door_provided, self_closing_mechanism, panic_hardware, inspection_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'areaOfSafeRefuges' => array(self::HAS_MANY, 'AreaOfSafeRefuge', 'exit_detail_id'),
			'inspection' => array(self::BELONGS_TO, 'Inspection', 'inspection_id'),
			'horizontalExits' => array(self::HAS_MANY, 'HorizontalExit', 'exit_detail_id'),
			'mainStairways' => array(self::HAS_MANY, 'MainStairway', 'exit_detail_id'),
			'meanOfEgresses' => array(self::HAS_MANY, 'MeanOfEgress', 'exit_detail_id'),
			'ramps' => array(self::HAS_MANY, 'Ramp', 'exit_detail_id'),
			'secondaryStairOrFireEscapes' => array(self::HAS_MANY, 'SecondaryStairOrFireEscape', 'exit_detail_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'occupant_load' => 'Occupant Load',
			'egress_capacity' => 'Egress Capacity',
			'capacity_of_horizontal_exit' => 'Capacity Of Horizontal Exit',
			'capacity_of_exit_stair' => 'Capacity Of Exit Stair',
			'no_of_exit' => 'No Of Exit',
			'remote' => 'Remote',
			'location_of_exit' => 'Location Of Exit',
			'enclosure_provided' => 'Enclosure Provided',
			'exit_accesible' => 'Exit Accesible',
			'discharge_of_exit' => 'Discharge Of Exit',
			'fire_door_provided' => 'Fire Door Provided',
			'self_closing_mechanism' => 'Self Closing Mechanism',
			'panic_hardware' => 'Panic Hardware',
			'inspection_id' => 'Inspection',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('occupant_load',$this->occupant_load);
		$criteria->compare('egress_capacity',$this->egress_capacity);
		$criteria->compare('capacity_of_horizontal_exit',$this->capacity_of_horizontal_exit);
		$criteria->compare('capacity_of_exit_stair',$this->capacity_of_exit_stair);
		$criteria->compare('no_of_exit',$this->no_of_exit);
		$criteria->compare('remote',$this->remote);
		$criteria->compare('location_of_exit',$this->location_of_exit,true);
		$criteria->compare('enclosure_provided',$this->enclosure_provided);
		$criteria->compare('exit_accesible',$this->exit_accesible);
		$criteria->compare('discharge_of_exit',$this->discharge_of_exit,true);
		$criteria->compare('fire_door_provided',$this->fire_door_provided);
		$criteria->compare('self_closing_mechanism',$this->self_closing_mechanism);
		$criteria->compare('panic_hardware',$this->panic_hardware);
		$criteria->compare('inspection_id',$this->inspection_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}